package binarySearchTree;

import student.TestCase;
import student.testingsupport.annotations.Hint;

/**
 * Test BinaryNode class.
 * @author xinruili
 * @version 1.0
 */
public class BinaryNodeTest extends TestCase {
    private BinaryNode<String> binaryNode;
    private BinaryNode<String> binaryNodeLeft;
    private BinaryNode<String> binaryNodeRight;

    /**
     * sets up any needed variables for test methods.
     * @author xinruili
     * @version 1.0
     */
    @Override
    public void setUp() {
        binaryNode = new BinaryNode<>("123");
        binaryNodeLeft = new BinaryNode<>("456");
        binaryNode.setLeft(binaryNodeLeft);
        binaryNodeRight = new BinaryNode<>("789");
        binaryNode.setRight(binaryNodeRight);
    }

    /**
     * testGetElement.
     */
    @Hint("GetElement is Right!")
    public void testGetElement() {
        assertEquals("123", binaryNode.getElement());
    }

    /**
     * testSetElement.
     */
    @Hint("SetElement is Right")
    public void testSetElement() {
        binaryNode.setElement("456");
        assertEquals("456", binaryNode.getElement());
    }

    /**
     * testGetLeft.
     */
    @Hint("GetLeft is Right")
    public void testGetLeft() {
        assertEquals(binaryNodeLeft, binaryNode.getLeft());
    }

    /**
     * testSetLeft.
     */
    @Hint("SetLeft is Right")
    public void testSetLeft() {
        BinaryNode<String> newBinaryNode = new BinaryNode<>("000");
        binaryNode.setLeft(newBinaryNode);
        assertEquals(newBinaryNode, binaryNode.getLeft());
    }

    /**
     * testGetRight.
     */
    @Hint("GetRight is Right")
    public void testGetRight() {
        assertEquals(binaryNodeRight, binaryNode.getRight());
    }

    /**
     * testSetRight.
     */
    @Hint("SetRight is Right")
    public void testSetRight() {
        BinaryNode<String> newBinaryNode = new BinaryNode<>("222");
        binaryNode.setRight(newBinaryNode);
        assertEquals(newBinaryNode, binaryNode.getRight());
    }

    /**
     * testToString.
     */
    @Hint("ToString is Right")
    public void testToString() {
        assertEquals("456, 123, 789", binaryNode.toString());
    }

}
